Skip to content

Add strrev() to NonEmptyStringFunctionsReturnTypeExtension #3921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.1.x
Choose a base branch
from

Conversation

nsfisis
Copy link

@nsfisis nsfisis commented Apr 6, 2025

Problem

If strrev() takes non-falsy-string or non-empty-string, it should return non-falsy-string or non-empty-string, but it returns just a string.

https://phpstan.org/r/f9b50c8a-1a20-43ff-8715-42f267a28e24

\PHPStan\dumpType(strrev("abc"));
// => string

Solution

Add strrev() to NonEmptyStringFunctionsReturnTypeExtension.

@VincentLanglet
Copy link
Contributor

Hi @nsfisis

Best would be to have a StrrevFunctionReturnTypeExtension because

  • We can know the strrev of a constant string
  • A lowercase string will still be lowercase
  • A uppercase string will still be uppercase

Do you want to try implementing it ?
I think StrRepeatFunctionReturnTypeExtension could be an help for the impelmentation idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants